<?php

namespace app\api\model\goods;

use think\Model;


class Goods extends Model
{

    

    

    // 表名
    protected $name = 'goods';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        
    ];

    public function getImageAttr($value, $data)
    {
        return $value ? cdnurl($value, true) : cdnurl('/assets/img/default.png', true);
    }
    
    public function goodsCategory()
    {
        return $this->hasOne('GoodsCategory', 'id','goods_category_id');
    }

    public function biaobenRongqi()
    {
        return $this->hasMany('BiaobenRongqi', 'id' , 'biaoben_rongqi_id');
    }

    public function biaobenType()
    {
        return $this->hasOne('BiaobenType', 'id' ,'biaoben_type_id');
    }



}
